package com.ssy.lingxi.system.controller;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.system.dto.request.*;
import com.ssy.lingxi.system.dto.response.MiddlegroundRoleDeatilsResponse;
import com.ssy.lingxi.system.dto.response.MiddlegroundRoleResponse;
import com.ssy.lingxi.system.dto.response.RoleButtonListResponse;
import com.ssy.lingxi.system.service.MiddlegroundRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
 * @menu 权限管理-中台角色管理
 * @author wrc
 * @date 2020/7/20
 */
@Api(tags = "中台角色管理")
@RestController
public class MiddlegroundRoleController {


    @Resource
    MiddlegroundRoleService middlegroundRoleService;


    @ApiOperation(value = " 查询角色列表")
    @GetMapping("/middleground/role/list")
    public Wrapper<PageData<MiddlegroundRoleResponse>> roleList(HttpServletRequest request, MiddlegroundRoleRequest middlegroundRoleRequest) {
        return middlegroundRoleService.roleList(request,middlegroundRoleRequest);
    }


    @ApiOperation(value = " 修改角色")
    @PostMapping("/middleground/role/update")
    public Wrapper roleUpdate(@RequestBody MiddlegroundRoleUpdateRequest middlegroundRoleRequest) {
        return middlegroundRoleService.roleUpdate(middlegroundRoleRequest);
    }

    @ApiOperation(value = " 添加角色")
    @PostMapping("/middleground/role/add")
    public Wrapper roleAdd(@RequestBody MiddlegroundRoleAddRequest middlegroundRoleRequest,HttpServletRequest request) {
        return middlegroundRoleService.roleAdd(request,middlegroundRoleRequest);
    }


    @ApiOperation(value = " 删除角色")
    @PostMapping("/middleground/role/delete")
    public Wrapper roleDelete(@RequestBody MiddlegroundRoleDeleteRequest middlegroundRoleRequest) {
        return middlegroundRoleService.roleDelete(middlegroundRoleRequest);
    }


    @ApiOperation(value = "停用&启用角色状态")
    @PostMapping("/middleground/role/update/state")
    public Wrapper roleUpdateState(@RequestBody RoleUpdateStateRequest request) {
        return middlegroundRoleService.roleUpdateState(request);
    }


    @ApiOperation(value = "角色详情&菜单列表查询")
    @GetMapping("/middleground/role/details")
    public Wrapper<MiddlegroundRoleDeatilsResponse> roleDetails(MiddlegroundRoleDeleteRequest request) {
        return middlegroundRoleService.roleDetails(request);
    }


    @ApiOperation(value = "角色按钮查询")
    @GetMapping("/middleground/button/list")
    public Wrapper<RoleButtonListResponse> roleButtonList(RoleButtonListRequest request) {
        return middlegroundRoleService.roleButtonList(request);
    }



}
